<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.2"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:u="urn:jsptagdir:/WEB-INF/tags/util/"
	xmlns:f="http://www.springframework.org/tags/form"
	xmlns:s="http://www.springframework.org/tags">
	<jsp:directive.page contentType="text/html" pageEncoding="UTF-8" />
	<c:url value="/resources" var="resourcesURL" />
	<script type="text/javascript" src="${resourcesURL}/js/transfer.js"><!-- --></script>
	<div class="page-header">
		<h1><s:message code="transfer.title" /></h1>
	</div>
	<f:form action="transfer" method="post" commandName="transferForm">
	    <div class="alert alert-info">
	    	<s:message code="transfer.help" />
		</div>
		<span id="errorJSSourceDestination" class="label label-important" hidden="true"><s:message code="AccountIdNotEquals" /></span>
		<f:errors path="" class="label label-important" />
		<div class="row">
			<div class="span6">
				<fieldset>
					<legend><s:message code="transfer.account.source" /> <f:errors path="accountSource" class="label label-important" /></legend>
					<table class="table table-striped">
						<thead>
							<tr>
								<th><s:message code="table.account.id.short" /></th>
								<th class="span3"><s:message code="table.account.label" /></th>
								<th><s:message code="table.account.balance" /></th>
								<th></th>
							</tr>
						</thead>
						<tbody>
							<c:forEach var="account" items="${accounts}">
								<tr>
									<td><f:label for="accountSource${account.accountId}" path="accountSource">${account.accountId}</f:label></td>
									<td><f:label for="accountSource${account.accountId}" path="accountSource">${account.label}</f:label></td>
									<td><f:label for="accountSource${account.accountId}" path="accountSource"><u:outBalance value="${account.balance}" /></f:label></td>
									<td><f:radiobutton path="accountSource" class="radioAccount" id="accountSource${account.accountId}" value="${account.accountId}" required="true" /></td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
				</fieldset>
			</div>
			<div class="span6">
				<fieldset>
					<legend class="align-right"><s:message code="transfer.account.destination" /> <f:errors path="accountDestination" class="label label-important" /></legend>
					<table class="table table-striped">
						<thead>
							<tr>
								<th></th>
								<th><s:message code="table.account.id.short" /></th>
								<th class="span3"><s:message code="table.account.label" /></th>
								<th><s:message code="table.account.balance" /></th>
							</tr>
						</thead>
						<tbody>
							<c:forEach var="account" items="${accounts}">
								<tr>
									<td><f:radiobutton class="radioAccount" path="accountDestination" id="accountDestination${account.accountId}" value="${account.accountId}" required="true" /></td>
									<td><f:label for="accountDestination${account.accountId}" path="accountDestination">${account.accountId}</f:label></td>
									<td><f:label for="accountDestination${account.accountId}" path="accountDestination">${account.label}</f:label></td>
									<td><f:label for="accountDestination${account.accountId}" path="accountDestination"><u:outBalance value="${account.balance}" /></f:label></td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
				</fieldset>
			</div>
		</div>
		<div class="form-horizontal">
			<div class="row">
				<div class="well span8 offset2">
					<div class="row">
						<div class="span4 offset1">
							<div class="control-group">
								<f:label for="amount" path="amount" class="control-label"><s:message code="table.transaction.amount" /></f:label>
								<div class="controls">
									<f:input type="text" id="amount" path="amount" pattern="^[0-9]{1,16}([,.][0-9]{1,2})?$" class="align-right" required="true" />
									<f:errors path="amount" class="label label-important" />
									<span id="errorJSAmount" class="label label-important" hidden="true"><s:message code="AmountIsValid" /></span>
								</div>
							</div>
						</div>
					</div>
					<div class="form-action">
						<div class="row">
							<div class="span2 offset3">
								<button type="submit" class="btn btn-large btn-primary" id="buttonTransfer"><s:message code="transfer.do" /></button>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</f:form>
</jsp:root>